package com.jiaai.web.member;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jiaai.member.api.IVisitApi;
import com.jiaai.member.model.VisitorVO;
import com.jiaai.util.HttpClientUtil;
import com.jiaai.util.RestResultGenerator;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * class_name:ZVisitorController
 * describe:游客
 * create_user:张昉平
 * create_date:2017/12/28
 * create_date:9:34
 */
@RestController
@RequestMapping("/api/v1/app/visit")
public class VisitorController {

    @Reference
    private IVisitApi visitApi;

    @PostMapping("/login")
    public Object login(@RequestParam String devId, @RequestParam Integer platform,  HttpServletRequest request){
        VisitorVO visitorVO = new VisitorVO();
        visitorVO.setDevId(devId);
        visitorVO.setPlatform(platform);
        visitorVO.setIpAddr(HttpClientUtil.getIpAddress(request));
        return RestResultGenerator.genSuccessResult(visitApi.login(visitorVO));
    }

}
